package cn.itcast.proxy;

/**
 * @author StormArcita
 * @date 2024-12-9 11:12
 */
public class CalculatorProxy implements Calculator{

    private Calculator calculator;

    public CalculatorProxy(Calculator calculator) {
        this.calculator = calculator;
    }

    @Override
    public int add(int i, int j) {
        //调用非核心功能
        System.out.println("日志功能：方法执行了，参数为"+i+","+j);

        //调用核心功能
        int result = calculator.add(i, j);

        //调用非核心功能
        System.out.println("日志功能：方法执行结束，结果为" + result);
        return result;
    }

    @Override
    public int sub(int i, int j) {
        return 0;
    }

    @Override
    public int mul(int i, int j) {
        return 0;
    }

    @Override
    public int div(int i, int j) {
        return 0;
    }
}
